<div class="SipeiInfo pt20"><!--阅卷准备_03理员任务维护_编辑-->
    <?php
    $form = $this->beginWidget('CActiveForm', array(
        'action' => $this->createUrl('/problem/question/alladd'),
        'method' => 'POST',
        'id' => 'searchForm',
        'htmlOptions' => array('target' => 'ajax-frame')
    ));
    ?>  
    <table class="fontc_666 height32" width="100%"> 
        <tbody>
            <tr height="55">
                <td valign="top" width="110" align="right" class="pr5"><span class="pr5 fontc_orange_red">*</span>所属考试项目：</td>
                <td valign="top" width="390" class="formValidator_td">
                    <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                        <span class="fl select_shelter">
                            <select class="fl fontc_666" name="exam_id" id="exam_id" onchange="checkexam(this.value)" >
                                <option value="0">请选择</option>
                                <?php if (!empty($exam)):foreach ($exam as $one): ?>
                                        <option value="<?php echo $one['exam_id']; ?>"><?php echo $one['exam_term_name']; ?></option>
                                        <?php
                                    endforeach;
                                endif;
                                ?>
                            </select>
                        </span>
                    </span>
                    <div class="formValidator_tip">
                        <p id="exam_idTip" ></p>
                    </div>
                </td>
            </tr>
            <tr height="55">
                <td valign="top" align="right" class="pr5"><span class="pr5 fontc_orange_red">*</span>所属科目：</td>
                <td valign="top" class="formValidator_td">
                    <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                        <span class="fl select_shelter">
                            <select class="fl fontc_666" name="subject_id" id="subject_id" onchange="checksubject(this.value);" >
                                <option value="0">请选择</option>
                                <?php if (!empty($subjectall)):foreach ($subjectall as $one): ?>
                                        <option value="<?php echo $one['subject_id']; ?>"><?php echo $one['subject_name']; ?></option>
                                        <?php
                                    endforeach;
                                endif;
                                ?>
                            </select>
                        </span>
                    </span> 
                    <div class="formValidator_tip">
                        <p id="subject_idTip" ></p>
                    </div>
                </td>
            </tr>
            <tr height="55">
                <td valign="top" align="right" class="pr5"><span class="pr5 fontc_orange_red">*</span>题型：</td>
                <td valign="top" class="formValidator_td">	
                    <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">
                        <span class="fl select_shelter">
                            <select class="fl fontc_666" name="num_type" id="num_type">
                            </select>
                        </span>
                    </span>
                    <div class="formValidator_tip">
                        <p id="num_typeTip" ></p>
                    </div>
                </td>
            </tr>
            <tr height="55">
                <td valign="top" align="right" class="pr5"><span class="pr5 fontc_orange_red">*</span>题号：</td>
                <td valign="top" class="formValidator_td">
                    <input type="text" name="num_id" id="num_id" value="(*)" class="col3 pt4 pr10 pb4 pl10 height20 border_c border_3 fontc_666"><font class="fontc_red pl5">(*)为通配符</font>
                    <div class="formValidator_tip">
                        <p id="num_idTip" ></p>
                    </div>
                </td>
            </tr>
            <tr height="55">
                <td valign="top" align="right" class="pr5"><input type="radio" name="gz" value="1" checked class="fr mt8 mr5" /></td>
                <td valign="top" class="">
                    从 <input type="text" name="start" id="start" value="1" style="width:20px;" class="col3 pt5 pr10 pb5 pl10 height20 border_c border_3 fontc_666"> 到 <input type="text" name="end" value="70" id="end" style="width:20px;" class="col3 pt5 pr10 pb5 pl10 height20 border_c border_3 fontc_666" />通配符长度：<input type="text" id="length" name="length" value="2" style="width:20px;" class="col3 pt5 pr10 pb5 pl10 height20 border_c border_3 fontc_666" /><font class="pl5 fontc_red">（长度1~3）</font>
                    <div class="formValidator_tip">
                        <p id="stringTip" ></p>
                    </div>
                </td>
            </tr>
            <tr height="55">
                <td valign="top" align="right" class="pr5"><input type="radio" name="gz" value="2" class="fr mt8 mr5" /></td>
                <td valign="top">
                    从 <input type="text" name="astart" id="astart" value="a" style="width:20px;" class="col3 pt5 pr10 pb5 pl10 height20 border_c border_3 fontc_666"> 到 <input type="text" name="aend" id="aend" value="z" style="width:20px;" class="col3 pt5 pr10 pb5 pl10 height20 border_c border_3 fontc_666" /><font style="color:red">（区分大小写）</font>
                    <div class="formValidator_tip">
                        <p id="letterTip" ></p>
                    </div>
                </td>
            </tr>
            <tr>
                <td colspan="2" align="center" class="pb20">
                    <input type="submit" value="保存" class="cursor b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 mr10" />
                    <input type="button" value="取消" onclick="api.close()" class="cursor b_a_n border_3 back_bgb w80 height32 fontc_FFF fonts_12" />
                </td>
            </tr>
        </tbody>
    </table>
    <?php
    $this->endWidget();
    ?>
</div>
<iframe src='' style="display:none" name='ajax-frame'></iframe>
<script>
                                $(function() {
                                    $.formValidator.initConfig({formID: "searchForm", theme: "126", submitOnce: false,
                                        onError: function(msg, obj, errorlist) {
                                            $("#errorlist").empty();
                                            $.map(errorlist, function(msg) {
                                                $("#errorlist").append("<li>" + msg + "</li>")
                                            });
                                            alert(msg);
                                        },
                                        ajaxPrompt: '有数据正在异步验证，请稍等...'
                                    });

                                    /*所属考试项目验证*/
                                    $("#exam_id").formValidator({
                                        onShowText: "",
                                        onShow: "",
                                        onFocus: "",
                                        onCorrect: "选择正确"
                                    }).inputValidator({
                                        min: 1,
                                        onError: "请选择考试项目"
                                    });

                                    /*所属科目验证*/
                                    $("#subject_id").formValidator({
                                        onShowText: "",
                                        onShow: "",
                                        onFocus: "",
                                        onCorrect: "选择正确"
                                    }).inputValidator({
                                        min: 1,
                                        onError: "请选择所属科目"
                                    });


                                    /*题号验证*/
                                    $("#num_id").formValidator({
                                        onShowText: "请输入题号",
                                        onShow: "",
                                        onFocus: "",
                                        onCorrect: "输入正确",
                                        leftTrim: true,
                                        rightTrim: true
                                    }).inputValidator({
                                        min: 1,
                                        onError: "题号不能为空"
                                    });

                                    /*所属科目验证*/
                                    $("#num_type").formValidator({
                                        onShowText: "",
                                        onShow: "",
                                        onFocus: "",
                                        onCorrect: "选择正确"
                                    }).inputValidator({
                                        min: 1,
                                        onError: "请选择题型"
                                    });

                                    $("#start").formValidator({
                                        tipID: "stringTip",
                                        onShowText: "",
                                        onShow: "",
                                        onFocus: "",
                                        onCorrect: "输入正确",
                                        leftTrim: true,
                                        rightTrim: true
                                    }).inputValidator({
                                        min: 1,
                                        max: 3,
                                        onError: "输入非法整数不超过三位数"
                                    }).regexValidator({
                                        regExp: "intege1",
                                        dataType: "enum",
                                        onError: "输入非法整数不超过三位数"
                                    }).functionValidator({
                                        fun: stringFn
                                    });
                                    $("#end").formValidator({
                                        tipID: "stringTip",
                                        onShowText: "",
                                        onShow: "",
                                        onFocus: "",
                                        onCorrect: "输入正确",
                                        leftTrim: true,
                                        rightTrim: true
                                    }).inputValidator({
                                        min: 1,
                                        max: 3,
                                        onError: "输入非法整数不超过三位数"
                                    }).regexValidator({
                                        regExp: "intege1",
                                        dataType: "enum",
                                        onError: "输入非法整数不超过三位数"
                                    }).functionValidator({
                                        fun: stringFn
                                    });
                                    $("#length").formValidator({
                                        tipID: "stringTip",
                                        onShowText: "",
                                        onShow: "",
                                        onFocus: "",
                                        onCorrect: "输入正确",
                                        leftTrim: true,
                                        rightTrim: true
                                    }).inputValidator({
                                        min: 1,
                                        max: 1,
                                        onError: "输入非法整数不超过一位数"
                                    }).regexValidator({
                                        regExp: "intege1",
                                        dataType: "enum",
                                        onError: "输入非法整数不超过一位数"
                                    }).functionValidator({
                                        fun: stringFn
                                    });
                                    ;

                                    $("#astart").formValidator({
                                        tipID: "letterTip",
                                        onShowText: "",
                                        onShow: "",
                                        onFocus: "",
                                        onCorrect: "输入正确",
                                        leftTrim: true,
                                        rightTrim: true
                                    }).inputValidator({
                                        min: 1,
                                        max: 1,
                                        onError: "请输入一位字母"
                                    }).regexValidator({
                                        regExp: "letter",
                                        dataType: "enum",
                                        onError: "请输入一位字母"
                                    });
                                    $("#aend").formValidator({
                                        tipID: "letterTip",
                                        onShowText: "",
                                        onShow: "",
                                        onFocus: "",
                                        onCorrect: "输入正确",
                                        leftTrim: true,
                                        rightTrim: true
                                    }).inputValidator({
                                        min: 1,
                                        max: 1,
                                        onError: "请输入一位字母"
                                    }).regexValidator({
                                        regExp: "letter",
                                        dataType: "enum",
                                        onError: "请输入一位字母"
                                    });


                                    function stringFn(val) {
                                        var msg = ""
                                        startVal = $("#start").val(),
                                                endVal = $("#end").val(),
                                                lengthVal = $("#length").val();
                                        if (startVal > endVal) {
                                            msg = "请输入正确规则";
                                        } else {
                                            msg = true;
                                        }

                                        return msg;

                                    }


                                })
//项目科目联动
                                function checkexam(val) {
                                    $.post('/question_collect/default/ajaxvalue', {id: val}, function(result) {
                                        var dataObj = eval("(" + result + ")");//转换为json对象
                                        var subjectstr = '';
                                        subjectstr += "<option value='0'>请选择</option>"
                                        $.each(dataObj, function(i, item) {
                                            subjectstr += "<option value='" + item.subject_id + "'>" + item.subject_name + "</option>"
                                        });
                                        $("#subject_id").html(subjectstr);
                                    });
                                }

                                function checksubject(val) {
                                    $.post('/question_collect/default/sujectquestions', {subject_id: val}, function(result) {
                                        var obj = $.parseJSON(result), newHtml = "";
                                        newHtml += "<option value='0'>请选择</option>"
                                        $.each(obj, function(i, item) {
                                            newHtml += "<option value='" + i + "'>" + item + "</option>"
                                        })
                                        $("#num_type").html(newHtml);
                                    });
                                }
</script>
<?php exit; ?>